package work5;

/**
 * 设计一个多线程的程序如下：设计一个火车售票模拟程序。假如火车站要有100张火车票要卖出，现在有5个售票点同时售票，用5个线程模拟这5个售票点的售票情况
 */
public class Test implements Runnable{
    private int ticket = 100;
    @Override
    public void run() {
        while (ticket > 0){
            System.out.println(Thread.currentThread().getName() + "销售了第" + ticket-- + "张票");
        }
    }

    public static void main(String[] args) {
        Test test = new Test();
        new Thread(test,"1号售票点").start();
        new Thread(test,"2号售票点").start();
        new Thread(test,"3号售票点").start();
        new Thread(test,"4号售票点").start();
        new Thread(test,"5号售票点").start();
    }
}
